const cloud = require('wx-server-sdk');

// const db = cloud.database({
// 	env:'roseannepark'
// })
const db = cloud.database()


exports.main = async (event, context)=>{
	// console.log(event, context);
	if(event.data.origin == undefined){
		let result = await cloud.openapi.security.msgSecCheck({
			content:event.data.edge_media_to_caption,
			version:2,
			scene:4,
			openid:event.data.shortcode,
		});
		// console.log("当前结果是:",result)
		if(result.result.label != 100){
			return {'msg':'fail','data':[]}
		}
	}
	await db.collection('user_edge').add({
		data:event.data
	});
	return {'msg':'ok','data':[]}
}